<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        body {
            font-size: 0;
            margin: 0;
        }

        div {
            width: 50px;
            height: 50px;
            background-color: #ccc;
            border: 1px solid #fff; 
            display: inline-block;
        }

        .red {
            background-color: red;
        }

        div:nth-of-type(2n) {
            background-color: red;
        }
        div:nth-of-type(2n-1) {
            background-color: green;
        }

    </style>
</head>
<body>
    <!-- <div class="red"></div> -->

    <script>
        // 定义字符串变量（牢记，变量是用于储存数据的）
        var str = "";
        // 数量
        var count = 5;
        // 循环
        for(var index = 1 ; index <= count ; index ++){
            // 拼接字符串
            str += '<div></div>'
        }
        // 渲染字符串(body)
        document.write(str);


    </script>
</body>
</html>